<?php

namespace app\index\controller;


use think\Controller;
use think\Request;
use think\Session;
use think\Db;

class Teacher extends Controller
{
    public function index()
    {
        $data = db('teacher')
            ->group('teasid')
            ->select();
        // var_dump($data);die;
        $a = [];
        foreach ($data as $v) {
            $b = '\uploads\\' . $v['icon'];
            $c = array_push($v, $b);
            $d = Db::name('teasort')
                ->field('teasort')
                ->where('id', $v['teasid'])
                ->find();
            $e = array_push($v, $d['teasort']);
            $a[] = $v;
        }
        return view('', [
            'data' => $a,
        ]);
    }

    //进入分类页面
    public function teasort($id)
    {
        //根据文章的ID查到该教师的分类,然后根据分类查到该分类下所有的教师
        $a = Db::name('teacher')
            ->field('teasid')
            ->where('id', $id)
            ->find();
        $b = Db::name('teasort')
            ->field('teasort')
            ->where('id', $a['teasid'])
            ->find();
        $c = $b['teasort'];
        $data = Db::name('teacher')
            ->where('teasid', $a['teasid'])
            ->select();

        // var_dump($data);die;
        return view('', [
            'data' => $data,
            'c' => $c
        ]);


    }


    //详情页面
    public function details($id)
    {
        // var_dump('123');die;
        $data = Db::name('teacher')
            ->where('id =' . $id)
            ->find();


        // var_dump($data);die;


        return View('', [

            'data' => $data
        ]);


    }

    public function tt()
    {
        $data = Db::name('teacher')->select();
        return json_encode($data);
    }

    public function ttt()
    {
//        $data = Db::name('teacher')->select();
//        return json_encode($data);
        return view();
    }


}

?>
